<?php if(!defined('IN_INSTALL')) exit("Request Error!"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>初始化数据库</title>
<link href="templets/style/install.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="templets/js/jquery.min.js"></script>
</head>
<body>
<div class="header">
		<div class="step_area"><!--img src="templets/images/extset.png" /--></div>
</div>
<div class="mainbody">
		<div class="step_sgin"><img src="templets/images/step_sgin_third.png" /></div>
		<h2 class="install_title">正在安装...</h2>
		<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
		<tr>
				<td>
				<div style="height:204px;line-height:24px;overflow:auto;" id="content_area"></div>
				</td>
		</tr>
</table>
</div>
<div class="footer">© 2012 m16888.cn</div>
</body>
</html>
<?php
if((int)$_GET['s'] == 3)
{
    //$dbinfo    = $_POST['dbinfo'];
	//$admininfo = $_POST['admininfo'];
    //$conn = @mysql_connect('localhost:3306','root','123456');
    $conn = @mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
	if($conn)
	{
		//mysql_select_db('misone_erp_sae', $conn);
        mysql_select_db(SAE_MYSQL_DB, $conn);
        
        //设置数据库状态
		mysql_query("SET NAMES 'utf8', character_set_client=binary, sql_mode='', interactive_timeout=3600;");

		//创建表结构
		$tbdata = '';
		$tbdata = Readf(INSTALL_PATH.'/data/install_struct.txt');
		$querys = explode(';', $tbdata);
		foreach($querys as $q)
		{
			if(trim($q) == '') continue;
			mysql_query(trim($q).';');
		}
        mysql_query("UPDATE `misone_faccmas` SET `diyinfo`='a:6:{s:4:\"bank\";s:1:\"N\";s:6:\"arctrl\";s:1:\"N\";s:6:\"apctrl\";s:1:\"N\";s:12:\"precollected\";s:1:\"N\";s:7:\"prepaid\";s:1:\"N\";s:6:\"profit\";s:1:\"N\";}' WHERE `diyinfo`='facc001';");
        mysql_query("UPDATE `misone_faccmas` SET `diyinfo`='a:6:{s:4:\"bank\";s:1:\"Y\";s:6:\"arctrl\";s:1:\"N\";s:6:\"apctrl\";s:1:\"N\";s:12:\"precollected\";s:1:\"N\";s:7:\"prepaid\";s:1:\"N\";s:6:\"profit\";s:1:\"N\";}' WHERE `diyinfo`='facc002';");
        mysql_query("UPDATE `misone_faccmas` SET `diyinfo`='a:7:{s:4:\"bank\";s:1:\"N\";s:6:\"arctrl\";s:1:\"N\";s:6:\"apctrl\";s:1:\"N\";s:12:\"precollected\";s:1:\"N\";s:7:\"prepaid\";s:1:\"N\";s:6:\"profit\";s:1:\"N\";s:6:\"credit\";s:1:\"Y\";}' WHERE `diyinfo`='facc003';");
        mysql_query("UPDATE `misone_faccmas` SET `diyinfo`='a:6:{s:4:\"bank\";s:1:\"N\";s:6:\"arctrl\";s:1:\"Y\";s:6:\"apctrl\";s:1:\"N\";s:12:\"precollected\";s:1:\"N\";s:7:\"prepaid\";s:1:\"N\";s:6:\"profit\";s:1:\"N\";}' WHERE `diyinfo`='facc004';");
        mysql_query("UPDATE `misone_faccmas` SET `diyinfo`='a:6:{s:4:\"bank\";s:1:\"N\";s:6:\"arctrl\";s:1:\"N\";s:6:\"apctrl\";s:1:\"N\";s:12:\"precollected\";s:1:\"N\";s:7:\"prepaid\";s:1:\"Y\";s:6:\"profit\";s:1:\"N\";}' WHERE `diyinfo`='facc005';");
        mysql_query("UPDATE `misone_faccmas` SET `diyinfo`='a:7:{s:4:\"bank\";s:1:\"N\";s:6:\"arctrl\";s:1:\"N\";s:6:\"apctrl\";s:1:\"Y\";s:12:\"precollected\";s:1:\"N\";s:7:\"prepaid\";s:1:\"N\";s:6:\"profit\";s:1:\"N\";s:6:\"credit\";s:1:\"Y\";}' WHERE `diyinfo`='facc006';");
        mysql_query("UPDATE `misone_faccmas` SET `diyinfo`='a:7:{s:4:\"bank\";s:1:\"N\";s:6:\"arctrl\";s:1:\"N\";s:6:\"apctrl\";s:1:\"N\";s:12:\"precollected\";s:1:\"Y\";s:7:\"prepaid\";s:1:\"N\";s:6:\"profit\";s:1:\"N\";s:6:\"credit\";s:1:\"Y\";}' WHERE `diyinfo`='facc007';");
        mysql_query("UPDATE `misone_faccmas` SET `diyinfo`='a:7:{s:4:\"bank\";s:1:\"N\";s:6:\"arctrl\";s:1:\"N\";s:6:\"apctrl\";s:1:\"N\";s:12:\"precollected\";s:1:\"N\";s:7:\"prepaid\";s:1:\"N\";s:6:\"profit\";s:1:\"Y\";s:6:\"credit\";s:1:\"Y\";}' WHERE `diyinfo`='facc008';");

		echo '<script>$("#content_area").append("数据库导入完成！<br />");</script>';      
        
        
		
		//安装完成进行跳转
		echo '<script>location.href="?s='.md5('done').'";</script>';
	}
	else
	{
		echo '<script>$("#content_area").append("数据库连接错误，请检查！");</script>';
	}
}
?>